﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using weikebuluo.DAL;
using weikebuluo.Common;
using weikebuluo.Model;


namespace weikebuluo.web.wechat.vip
{
    public partial class coupanlist : System.Web.UI.Page
    {
        v_coupon_dal coupondal = new v_coupon_dal();
        v_couponlog_dal couponlogdal = new v_couponlog_dal();
        v_couponlog_model couponlogmodel = new v_couponlog_model();
        protected DataTable dtcoupon = new DataTable();
        protected DataTable dt1 = new DataTable();
        protected DataTable dt = new DataTable();
        protected string url = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            url = "http://" + Request.Url.Authority + "/web/wechat/vip/coupanuse.aspx?id=";
            if (!string.IsNullOrEmpty(Request.QueryString["uid"])) {
                dtcoupon = coupondal.GetList("user_id=" + Request.QueryString["uid"]).Tables[0];
            }
            if (!string.IsNullOrEmpty(Request.QueryString["wxid"]))
            {
                dt1 = couponlogdal.GetList(" couponlog_stutas=0 and wxid='" + Request.QueryString["wxid"]+"'").Tables[0];
            }
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                dt = couponlogdal.GetList("coupon_id=" + Request.QueryString["id"]).Tables[0];
                if (dt.Rows.Count > 0)
                {

                }
                else {
                    couponlogmodel.coupon_id = int.Parse(Request.QueryString["id"].ToString());
                    couponlogmodel.wxid = Request.QueryString["wxid"];
                    couponlogmodel.couponlog_stutas = 0;
                    couponlogdal.Add(couponlogmodel);
                    Response.Write("<script Language=\"Javascript\">alert(\"成功\")");
                    Response.Write("</script>");
                    Response.Write("<script Language=\"Javascript\">location.href=\"coupanlist.aspx?uid="+Request.QueryString["uid"] +"&wxid="+Request.QueryString["wxid"]+"\";");
                    Response.Write("</script>");
                    Response.End();
                }
            }
        }
    }
}